package com.example.app2024.navigationButtom;

import android.os.Bundle;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.ui.AppBarConfiguration;
import androidx.navigation.ui.NavigationUI;

import com.example.app2024.R;
import com.google.android.material.bottomnavigation.BottomNavigationView;

public class ButtomNaviActivity extends AppCompatActivity
{

      @Override
      protected void onCreate(Bundle savedInstanceState)
      {
            super.onCreate(savedInstanceState);
            EdgeToEdge.enable(this);
            setContentView(R.layout.activity_buttom_navi3);
            ViewCompat.setOnApplyWindowInsetsListener(
                    findViewById(R.id.main), (v, insets) -> {
                          Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
                          v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
                          return insets;
                    });



      }

      @Override
      protected void onStart()
      {
            super.onStart();
            BottomNavigationView bottomNavigationView = findViewById(R.id.mybuttomnavi);
            //       fragmentContainerView5  系统加入的是 fragmentContainerView , 必须手工改成 framgment
            NavController navController = Navigation.findNavController(this, R.id.fragmentContainerView5);
            //AppBarConfiguration configuration = new AppBarConfiguration.Builder(navController.getGraph()).build(); 等同于一句
            AppBarConfiguration configuration = new AppBarConfiguration.Builder(bottomNavigationView.getMenu()).build();
            //NavigationUI.setupActionBarWithNavController(this, navController, configuration);
            NavigationUI.setupWithNavController(bottomNavigationView, navController);
      }
}